package com.pubinfo.passbook.common.service.master.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pubinfo.passbook.common.entity.TSystemUser;
import com.pubinfo.passbook.common.mapper.TSystemUserMapper;
import com.pubinfo.passbook.common.model.dto.system.UserListParam;
import com.pubinfo.passbook.common.model.dto.system.UserParam;
import com.pubinfo.passbook.common.model.vo.base.JsonResult;
import com.pubinfo.passbook.common.service.master.TSystemUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import javax.servlet.http.Cookie;
import java.util.List;
import java.util.UUID;

/**
 *
 */
@Service
@Slf4j
public class TSystemUserServiceImpl extends ServiceImpl<TSystemUserMapper, TSystemUser>
    implements TSystemUserService {
  
  @Override
  public Boolean installUser(UserParam userParam) {
    TSystemUser user = new TSystemUser();
    String salt = UUID.randomUUID().toString();
    user.setUsername(userParam.getUsername());
    //  SimpleHash sh = new SimpleHash(
    // "MD5",//algorithmName加密算法
    //   userParam.getPassword(),//source 被加密的对象
    //    salt, //salt 盐值
    //    1);//hashIterations 加密
    user.setSalt(salt);
    // user.setPassword(sh.toHex());
    return save(user);
  }
  
  @Override
  public IPage<TSystemUser> listUser(UserListParam param) {
    IPage<TSystemUser> iPage = page(param.getPage("create_time"));
    return this.baseMapper.listUser(iPage, param);
  }
  
}




